<?php
//============================================================+
// File name   : example_050.php
// Begin       : 2009-04-09
// Last Update : 2011-09-22
//
// Description : Example 050 for TCPDF class
//               2D Barcodes
//
// Author: Nicola Asuni
//
// (c) Copyright:
//               Nicola Asuni
//               Tecnick.com s.r.l.
//               Via Della Pace, 11
//               09044 Quartucciu (CA)
//               ITALY
//               www.tecnick.com
//               info@tecnick.com
//============================================================+

/**
 * Creates an example PDF TEST document using TCPDF
 * @package com.tecnick.tcpdf
 * @abstract TCPDF - Example: 2D barcodes.
 * @author Nicola Asuni
 * @since 2008-03-04
 */

require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->setLanguageArray($l);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Constantin Bogza');
$pdf->SetTitle('Invoice');
$pdf->SetSubject('Translation services invoice');
$pdf->SetKeywords('linguisticguide, invoice');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);


// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// NOTE: 2D barcode algorithms must be implemented on 2dbarcode.php class file.

// set font
$pdf->SetFont('helvetica', '', 11);
// set default font subsetting mode


// add a page
$pdf->AddPage();

// print a message
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="0">
 <tr nobr="true">
  <th  align="left" colspan="2"><br/><br/><br/><b>Invoice / Factura</b></th>
  <th></th>
  <th></th>
 </tr>
 <tr nobr="true">
  <th>Invoice series / Seria: </th>
  <th align="right">CBT</th>
  <th></th>
  <th></th>
 </tr>
 <tr nobr="true">
  <td>Invoice no. / Numarul: </td>
  <th align="right">321873216</th>
  <td></td>
  <th></th>
 </tr>
<tr nobr="true">
  <td>Date / Data: </td>
  <th align="right">03.12.2012<br/><br/><br/><br/></th>
  <td></td>
  <th></th>
</tr>
</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');



$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="0">
<tr nobr="true">
  <td colspan="4">Bogza Constantin<br/>Persoana Fizica Autorizata<br/></td>
  <td></td>
  <td colspan="4">Customer/Client: John Doe</td>
 </tr>
 <tr nobr="true">
  <td colspan="4">Tax Identification Code/CIF: 46512212</td>
  <td ></td>
  <td colspan="4">Tax Identification Code/CIF: 87855422</td>
 </tr>
 <tr nobr="true">
  <td colspan="4">Licence no./Autorizatie: 46512212</td>
  <td ></td>
  <td colspan="4"></td>
 </tr>
 <tr nobr="true">
  <td colspan="4">Address/Adresa: Str. Radu Voda Nr.6 Bl.777 Sc.A Ap. 14 <br/>Iasi <br/>Romania</td>
  <td ><br /></td>
  <td colspan="4">Address/Adresa: Str. Radu Voda Nr.6 Bl.777 Sc.A Ap. 14 <br/>Germany</td>
 </tr>
 <tr nobr="true">
  <td colspan="4">Bank account/Cont bancar: 45656456465123</td>
  <td ></td>
  <td colspan="4">Bank account/Cont bancar: 21321854532121</td>
 </tr>
 <tr nobr="true">
  <td colspan="4">Bank/Banca: Transilvania</td>
  <td></td>
  <td colspan="4">Bank/Banca: Volksbank</td>
 </tr>
 <tr nobr="true">
  <td colspan="4"></td>
  <td ></td>
  <td colspan="4">PO no./Numar OP: 2<br/><br/><br/></td>
 </tr>
</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');

// ---------------------------------------------------------


$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
 <tr nobr="true">
  <th colspan="4">Services/Sevicii</th>
  <th align="right">Amount/Valoare</th>
 </tr>
 <tr nobr="true">
  <td colspan="4">Translation services for the file Testfile.doc<br/><br/><br/><br/></td>
  <td align="right">45&euro; / 203 RON</td>
 </tr>
 <tr nobr="true">
  <td colspan="4">Total amount to be paid/Total plata:</td>
  <td align="right">45&euro; / 203 RON</td>
 </tr>
 <tr nobr="true">
  <td>Signature and stamp of the service provider/<br/>Semnatura si stampila furnizorului<br/><br/><br/></td>
  <td colspan="3">Buyer cotact/ Delegat: John Doe<br/>Phone/Telefon: 0045412544<br/>Email: john.doe@hiscompany.com</td>
  <td>Receipt signature/ Semnatura de primire</td>
 </tr>
</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');

// ---------------------------------------------------------
// Set the QR code for the invoice
// new style
$style = array(
    'border' => true,
    'padding' => 0,
    'fgcolor' => array(0,0,0),
    'bgcolor' => false
);

// QRCODE,H : QR-CODE Best error correction
$pdf->write2DBarcode('www.linguisticguide.com', 'QRCODE,H', 170, 30, 30, 30, $style, 'N');

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('Invoice.pdf', 'I');

//============================================================+
// END OF FILE
//============================================================+
?>